<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('新增人员请假审核')" />
    <th:block th:include="include :: datetimepicker-css" />
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-check-add">
            <h4 class="form-header h4">人员请假审核信息</h4>
            <div class="form-group">    
                <label class="col-sm-3 control-label">请假ID：</label>
                <div class="col-sm-8">
                    <input name="askId" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">请假人员：</label>
                <div class="col-sm-8">
                    <input name="zhmkUserId" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">请假事由：</label>
                <div class="col-sm-8">
                    <textarea name="reason" class="form-control"></textarea>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">审核用户：</label>
                <div class="col-sm-8">
                    <input name="userId" class="form-control" type="text">
                </div>
            </div>
           <!-- <div class="form-group">
                <label class="col-sm-3 control-label">移交状态：</label>
                <div class="col-sm-8">
                    <input name="turnStatus" class="form-control" type="text">
                </div>
            </div>-->
            <div class="form-group">    
                <label class="col-sm-3 control-label">审核状态：</label>
                <div class="col-sm-8">
                   <!-- <input name="gradeStatus" class="form-control" type="text">-->
                    <div class="radio-box" th:each="dict : ${@dict.getType('zhmk_check_status')}">
                        <input type="radio" th:id="${'status_' + dict.dictCode}" name="gradeStatus" th:value="${dict.dictValue}" th:checked="${dict.default}">
                        <label th:for="${'status_' + dict.dictCode}" th:text="${dict.dictLabel}"></label>
                    </div>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">请假状态：</label>
                <div class="col-sm-8">
                    <!--<input name="status" class="form-control" type="text">-->
                    <div class="radio-box" th:each="dict : ${@dict.getType('zhmk_ask_status')}">
                        <input type="radio" th:id="${'status_' + dict.dictCode}" name="status" th:value="${dict.dictValue}" th:checked="${dict.default}">
                        <label th:for="${'status_' + dict.dictCode}" th:text="${dict.dictLabel}"></label>
                    </div>
                </div>
            </div>
            <!--<div class="form-group">
                <label class="col-sm-3 control-label">删除标志：</label>
                <div class="col-sm-8">
                    <input name="delFlag" class="form-control" type="text">
                </div>
            </div>-->
            <div class="form-group">    
                <label class="col-sm-3 control-label">出门时间：</label>
                <div class="col-sm-8">
                    <div class="input-group date">
                        <input name="outDate" class="form-control" placeholder="yyyy-MM-dd" type="text">
                        <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                    </div>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">归队时间：</label>
                <div class="col-sm-8">
                    <div class="input-group date">
                        <input name="comeDate" class="form-control" placeholder="yyyy-MM-dd" type="text">
                        <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                    </div>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">逾期时间：</label>
                <div class="col-sm-8">
                    <div class="input-group date">
                        <input name="beyondDate" class="form-control" placeholder="yyyy-MM-dd" type="text">
                        <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                    </div>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">备注：</label>
                <div class="col-sm-8">
                    <textarea name="remark" class="form-control"></textarea>
                </div>
            </div>
            <h4 class="form-header h4">请假信息</h4>
            <div class="row">
                <div class="col-sm-12">
                    <button type="button" class="btn btn-white btn-sm" onclick="addColumn()"><i class="fa fa-plus"> 增加</i></button>
                    <button type="button" class="btn btn-white btn-sm" onclick="sub.delColumn()"><i class="fa fa-minus"> 删除</i></button>
                    <div class="col-sm-12 select-table table-striped">
                        <table id="bootstrap-table"></table>
                    </div>
                </div>
            </div>
        </form>
    </div>
    <th:block th:include="include :: footer" />
    <th:block th:include="include :: datetimepicker-js" />
    <script th:inline="javascript">
        var prefix = ctx + "zhmk/check"
        var userTypeDatas = [[${@dict.getType('zhmk_user_status')}]];
        var statusDatas = [[${@dict.getType('zhmk_user_status')}]];
        $("#form-check-add").validate({
            focusCleanup: true
        });

        function submitHandler() {
            if ($.validate.form()) {
                $.operate.save(prefix + "/add", $('#form-check-add').serialize());
            }
        }

        $("input[name='outDate']").datetimepicker({
            format: "yyyy-mm-dd",
            minView: "month",
            autoclose: true
        });

        $("input[name='comeDate']").datetimepicker({
            format: "yyyy-mm-dd",
            minView: "month",
            autoclose: true
        });

        $("input[name='beyondDate']").datetimepicker({
            format: "yyyy-mm-dd",
            minView: "month",
            autoclose: true
        });

        $(function() {
            var options = {
                pagination: false,
                showSearch: false,
                showRefresh: false,
                showToggle: false,
                showColumns: false,
                sidePagination: "client",
                columns: [{
                    checkbox: true
                },
                {
                    field: 'index',
                    align: 'center',
                    title: "序号",
                    formatter: function (value, row, index) {
                    	var columnIndex = $.common.sprintf("<input type='hidden' name='index' value='%s'>", $.table.serialNumber(index));
                    	return columnIndex + $.table.serialNumber(index);
                    }
                },
                {
                    field: 'userId',
                    align: 'center',
                    title: '人员ID',
                    formatter: function(value, row, index) {
                        var html = $.common.sprintf("<input class='form-control' type='text' name='zhmkAskList[%s].userId' value='%s'>", index, value);
                        return html;
                    }
                },
                {
                    field: 'userType',
                    align: 'center',
                    title: '人员状态',
                    formatter: function(value, row, index) {
                        var name = $.common.sprintf("zhmkAskList[%s].userType", index);
                        return $.common.dictToSelect(userTypeDatas, value, name);
                    }
                },
                {
                    field: 'status',
                    align: 'center',
                    title: '请假状态',
                    formatter: function(value, row, index) {
                        var name = $.common.sprintf("zhmkAskList[%s].status", index);
                        return $.common.dictToSelect(statusDatas, value, name);
                    }
                },
                {
                    field: 'delFlag',
                    align: 'center',
                    title: '删除标志',
                    formatter: function(value, row, index) {
                        var html = $.common.sprintf("<input class='form-control' type='text' name='zhmkAskList[%s].delFlag' value='%s'>", index, value);
                        return html;
                    }
                },
                {
                    field: 'askStartDate',
                    align: 'center',
                    title: '开始时间',
                    formatter: function(value, row, index) {
                        var html = $.common.sprintf("<input class='form-control' type='text' name='zhmkAskList[%s].askStartDate' value='%s'>", index, value);
                        return html;
                    }
                },
                {
                    field: 'askEndDate',
                    align: 'center',
                    title: '结束时间',
                    formatter: function(value, row, index) {
                        var html = $.common.sprintf("<input class='form-control' type='text' name='zhmkAskList[%s].askEndDate' value='%s'>", index, value);
                        return html;
                    }
                },
                {
                    field: 'createBy',
                    align: 'center',
                    title: '创建者',
                    formatter: function(value, row, index) {
                        var html = $.common.sprintf("<input class='form-control' type='text' name='zhmkAskList[%s].createBy' value='%s'>", index, value);
                        return html;
                    }
                },
                {
                    field: 'createTime',
                    align: 'center',
                    title: '创建时间',
                    formatter: function(value, row, index) {
                        var html = $.common.sprintf("<input class='form-control' type='text' name='zhmkAskList[%s].createTime' value='%s'>", index, value);
                        return html;
                    }
                },
                {
                    field: 'updateBy',
                    align: 'center',
                    title: '更新者',
                    formatter: function(value, row, index) {
                        var html = $.common.sprintf("<input class='form-control' type='text' name='zhmkAskList[%s].updateBy' value='%s'>", index, value);
                        return html;
                    }
                },
                {
                    field: 'updateTime',
                    align: 'center',
                    title: '更新时间',
                    formatter: function(value, row, index) {
                        var html = $.common.sprintf("<input class='form-control' type='text' name='zhmkAskList[%s].updateTime' value='%s'>", index, value);
                        return html;
                    }
                },
                {
                    field: 'remark',
                    align: 'center',
                    title: '备注',
                    formatter: function(value, row, index) {
                        var html = $.common.sprintf("<input class='form-control' type='text' name='zhmkAskList[%s].remark' value='%s'>", index, value);
                        return html;
                    }
                
                }]
            };
            $.table.init(options);
        });

        function addColumn() {
            var count = $("#" + table.options.id).bootstrapTable('getData').length;
            sub.editColumn();
        	
            $("#" + table.options.id).bootstrapTable('insertRow', {
                index: count,
                row: {
                    index: $.table.serialNumber(count),
                    userId: "",
                    userType: "",
                    status: "",
                    delFlag: "",
                    askStartDate: "",
                    askEndDate: "",
                    createBy: "",
                    createTime: "",
                    updateBy: "",
                    updateTime: "",
                    remark: ""
                }
            });
        }
    </script>
</body>
</html>